const Koa = require('koa')
// const { default: koaBody } = require('koa-body')
const { koaBody } = require('koa-body')
const goodsRouter = require('../router/goodsRouter')
const cartUsersRouter = require('../router/cartUsersRouter')
const errHandler = require('./errHandler')

const app = new Koa()

// 在注册路由前注册
app.use(koaBody())

// 必须是一个函数
app.use(cartUsersRouter.routes())
app.use(goodsRouter.routes())

app.on('error', errHandler)

module.exports = app